package Visitor;

import java.util.ArrayList;

public class Section implements IDocument{

	String title ;
	ArrayList<IDocument> children = new ArrayList<IDocument>();
	
	
	public Section(String title){
		this.title = title;
	}
	
	public Section add(IDocument doc){
		children.add(doc);
		return this;
	}
	
	
	
	@Override
	public boolean contains(String s) {
		
		for(IDocument d : children){
			if(d.contains(s))
				return true;
			
		}
		
		return false;
	}

	@Override
	public void Accept(IVisitor v) {
		
		v.visit(this);
		
		for(IDocument doc : children){
			doc.Accept(v);
		}
	}

}
